﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Caliburn.Micro;
using System.Diagnostics.Contracts;

namespace NavTest2
{
    public class AppNavigationService : Conductor<Screen>.Collection.OneActive, IApplicationService, IApplicationLifetimeAware
    {

        public void Navigate(string navigateTo)
        {
            Contract.Assert(!String.IsNullOrEmpty(navigateTo));
            if (this.ContentFrame != null)
            {
                this.ContentFrame.Navigate(new Uri(navigateTo, UriKind.Relative));
            }
        }

        public Frame ContentFrame { private get; set; }

        private static AppNavigationService  _current = null;

        public static AppNavigationService Current
        {
            get { return _current; }
        }

        #region IApplicationService Members

        public void StartService(ApplicationServiceContext context)
        {
            _current = this;
            //MessageBox.Show("StartService");
            //throw new NotImplementedException();
        }

        public void StopService()
        {
            _current = null;
            //MessageBox.Show("StopService");
            //throw new NotImplementedException();
        }

        #endregion

        #region IApplicationLifetimeAware Members

        public void Exited()
        {
            //MessageBox.Show("Exited");
            //throw new NotImplementedException();
        }

        public void Exiting()
        {
            //MessageBox.Show("Exiting");
            //throw new NotImplementedException();
        }

        public void Started()
        {
            //MessageBox.Show("Started");
            //throw new NotImplementedException();
        }

        public void Starting()
        {
            //MessageBox.Show("Starting");
            //throw new NotImplementedException();
        }

        #endregion
    }
}
